import { Space } from 'antd';
import unloadImg from '@/assets/unload.svg'
import freezeImg from '@/assets/freeze.svg'
import unfreezeImg from '@/assets/unfreeze.svg'

export const getColumns = (doUnload, doFreeze) => {
    const columns = [
        {
            title: '包名',
            dataIndex: 'name',
            key: 'name',
            width: 660,
            render: (text) => <a>{text}</a>,
        },
        {
            title: '操作',
            key: 'action',
            render: (_, record) => (
                <Space size="middle">
                    <a className='actionItem' onClick={()=>{doUnload(record)}}><img style={{marginRight: 3}} src={unloadImg} /> 卸载</a>
                    {record.disable?
                        <a className='actionItem' onClick={()=>{doFreeze(record, true)}}><img style={{position: 'relative', left: '-4px'}} src={unfreezeImg} /> 解冻</a>:
                        <a className='actionItem' onClick={()=>{doFreeze(record)}}><img style={{marginRight: 3}} src={freezeImg} /> 冻结</a>
                    }
                    
                </Space>
            ),
        },
    ];
    return columns
}

